var list= [
  { 'id': '29', 'pid': '',     'name': '总裁办' },
  { 'id': '2c', 'pid': '',     'name': '财务部' },
  { 'id': '2d', 'pid': '2c', 'name': '财务核算部'},
  { 'id': '2f', 'pid': '2c', 'name': '薪资管理部'},
  { 'id': 'd2', 'pid': '',     'name': '技术部'},
  { 'id': 'd3', 'pid': 'd2', 'name': 'Java研发部'}
]
// 递归解决树形数据转换
function digui (arr,pid='') {
  let newArr = []
  arr.forEach(ele => {
    if (ele.pid == pid) {
      let child = digui(arr,ele.id)
      if (child.length) {
        ele.children = child
      }
      newArr.push(ele)
    }
  })
  return newArr
}

console.log(digui(list))
function parseTime(time, cFormat) {
  if (arguments.length === 0 || !time) {
    return null
  }
  const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
  let date
  if (typeof time === 'object') {
    date = time
  } else {
    if ((typeof time === 'string')) {
      if ((/^[0-9]+$/.test(time))) {
        // support "1548221490638"
        time = parseInt(time)
      } else {
        // support safari
        // https://stackoverflow.com/questions/4310953/invalid-date-in-safari
        time = time.replace(new RegExp(/-/gm), '/')
      }
    }

    if ((typeof time === 'number') && (time.toString().length === 10)) {
      time = time * 1000
    }
    date = new Date(time)
  }
  const formatObj = {
    y: date.getFullYear(),
    m: date.getMonth() + 1,
    d: date.getDate(),
    h: date.getHours(),
    i: date.getMinutes(),
    s: date.getSeconds(),
    a: date.getDay()
  }
  const time_str = format.replace(/{([ymdhisa])+}/g, (result, key) => {
    const value = formatObj[key]
    // Note: getDay() returns 0 on Sunday
    if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
    return value.toString().padStart(2, '0')
  })
  return time_str
}
    //格式化日期
    function formatDate(time) {
      let dt = new Date(time)
      let y = dt.getFullYear() //2021
      /* 1-12月对应 0-11下标 */
      let m = padZore (dt.getMonth()+1) //10  10下标是第11月
      let d = padZore (dt.getDate() )//11
      /* 星期天-星期6   0-6 */
      let hh = padZore (dt.getHours() )//15
      let mm = padZore (dt.getMinutes() )//57
      let ss = padZore (dt.getSeconds() )//12
      return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
  }
  function padZore (n) {
      return n<10?'0'+n:n
  }
console.log(formatDate('2018-11-02T08:00:00.000+0000'))